# @Author   : 懒羊羊
# @File     : doSQL.py
# @Time     : 2024/12/23 17:17

# 实现数据库连接
# 使用pymysql 实现数据库的操作

import pymysql

# 连接数据库
dbc = pymysql.connect(user='root', password='123456', database='crm9', port=3306, host='192.168.88.100')

# 通过cursor 来操作数据库
# 使用到游标（cursor）对象来执行SQL查询
runner = dbc.cursor()

sql = "SELECT log_id from 72crm_oa_log where create_user_id =(SELECT user_id from 72crm_admin_user where username='admin');"

# 获取查询的结果数
s = runner.execute(sql)

s1 = runner.fetchone()
s2 = runner.fetchmany(3)
s3 = runner.fetchall()

print(s)
# print(s1)
# print(s2)
print(s3)
